//package test6;
//
//import java.io.*;
//
///**
// * Created with IntelliJ IDEA.
// * Description:
// * User: Hua YY
// * Date: 2025-02-05
// * Time: 13:37
// */
////序列化和反序列化实现深拷贝
//
//class Person implements Serializable{
//   public String name;
//   public int age;
//   public Address address;
//   public Person(String name , int age , Address address){
//       this.name = name;
//       this.age = age;
//       this.address = address;
//   }
//   public Person deepClone(Person person) throws IOException, ClassNotFoundException {
//       ByteArrayOutputStream bos = new ByteArrayOutputStream();
//       ObjectOutputStream oos = new ObjectOutputStream(bos);
//       oos.writeObject(person);
//
//       ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
//       ObjectInputStream ois = new ObjectInputStream(bis);
//       return (Person)ois.readObject();
//   }
//
//}
//class Address implements Serializable{
//    public String city;
//    public Address(String city){
//        this.city = city;
//    }
//}
//public class Test2 {
//    public static void main(String[] args) throws IOException, ClassNotFoundException {
//        Address address = new Address("杭州");
//        Person person1 = new Person("张三",18,address);
//        Person person2 = person1.deepClone(person1);
//        System.out.println(person1.address == person2.address);
//    }
//
//}
